package com.li.controller;

import com.li.entity.Music;
import com.li.service.MusicService;
import com.li.utils.Result;
import com.li.utils.Test;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * @author li
 * @version 1.0
 * @ClassName MusicController
 * @description: TODO
 * @date 2025年02月06日
 */
@RestController
@RequestMapping("/music")
@Slf4j
public class MusicController {


    @Autowired
    private MusicService musicService;

    @GetMapping("/getById/{id}")
    public Result<Music> test(@PathVariable Integer id) {
        log.info("开始");
        String test = Test.test();
        log.info("结束" + test);
        Music music = musicService.getById(id);

//        if (Objects.isNull(music)){
//            return test + id;
//        }
        log.info("查询结果{}",music);
        return Result.success(music);
    }
}
